-- @owner: @songjing20
-- @date: 2023-1-16
-- @testpoint: desc/describe分析execute语句

--step1:创建两张表插入数据;expect:成功
drop table if exists t_describe_0074_01, t_describe_0074_02 cascade;
create table t_describe_0074_01 (cd_demo_sk integer not null, cd_gender character(16), cd_marital_status character(100));
insert into t_describe_0074_01 values(51, 'AAAAAAAADDAAAAAA', 't_describe_0074_01 51');
create table t_describe_0074_02 as table t_describe_0074_01;

--step2:为一个insert语句创建一个预备语句;expect:成功
prepare insert_reason(integer, character(16), character(100)) as insert into t_describe_0074_02 values($1, $2, $3);

--step3:执行预备语句(t_describe_0074_02表插入一条数据);expect:成功
execute insert_reason(52, 'AAAAAAAADDAAAAAA', 't_describe_0074_01 52');
select * from t_describe_0074_02;

--step4:开启事务explain analyze执行预备语句(t_describe_0074_02表插入一条数据);expect:打印执行计划
start transaction;
desc analyze verbose execute insert_reason(53, 'AAAAAAAADDAAAAAA', 't_describe_0074_01 53');
select * from t_describe_0074_02;
rollback;
select * from t_describe_0074_02;
begin;/
describe analyze verbose execute insert_reason(53, 'AAAAAAAADDAAAAAA', 't_describe_0074_01 53');
end;
select * from t_describe_0074_02;

--step5:清理环境;expect:成功
drop table if exists t_describe_0074_01, t_describe_0074_02 cascade;
deallocate insert_reason;